import { legacy_createStore, applyMiddleware } from "redux";
import reducer from "./reducer";
import mySaga from "./sagas";

import createSagaMiddleware from "redux-saga";
const sagaMiddleware = createSagaMiddleware();

// 跟thunk不同的是，applyMiddleware的参数是saga的返回值
const store = legacy_createStore(reducer, applyMiddleware(sagaMiddleware));

// 多一步mySage
sagaMiddleware.run(mySaga);

export default store;
